1. Array.findLast() and Array.findLastIndex() First up is the “Array find from last” feature, proposed by Wenlu Wang. It introduces two new methods for Array and TypedArray objects: findLast() and findLastIndex(). These methods function similarly to their existing counterparts (find() and findIndex()), but, as the names suggest, they start searching from the end of the array rather than the beginning. This… Continue reading 4 JavaScript Features in ES2023 That You Should Know
Tag: javascript
8 JavaScript Features in ES2019 That You Should Know
1. Array.prototype.{flat,flatMap} Array.prototype.flat() proposed to flatten arrays recursively up to the specified depth and returns a new array. Syntax: Array.prototype.flat(depth)depth — Default value 1, Use Infinity to flatten all nested arrays. Array.prototype.flatMap() maps each element using a mapping function and flattens the result into a new array. It’s identical to the map operation followed by a flat of depth 1. Syntax: Array.prototype.flatMap(callback)callback: function that produces an element of the new Array.… Continue reading 8 JavaScript Features in ES2019 That You Should Know
7 New JavaScript Features in ES2022 That You Should Know
1. RegExp match indices By using regular expressions, we can search for patterns in strings. Regexp.exec and String.matchAll are two methods used in JavaScript to retrieve a list of matches. Both return the matched substrings; the initial input string; the index in the input where the match was found; and the group’s object, consisting of substrings for any named… Continue reading 7 New JavaScript Features in ES2022 That You Should Know
10 New JavaScript Features in ES2020 That You Should Know
#1: BigInt BigInt, one of the most anticipated features in JavaScript, is finally here. It actually allows developers to have much greater integer representation in their JS code for data processing for data handling. At the moment the maximum number you can store as an integer in JavaScript is pow(2, 53) – 1 . But BigInt actually… Continue reading 10 New JavaScript Features in ES2020 That You Should Know
How not to Sort an Array In JavaScript
Array sorting is one of those things you don’t spend too long thinking about, until it stops working for you. Recently I was working with array of items in JavaScript that were not sorting at all properly and completely messing up an interface. It took me way too long to work out what went wrong… Continue reading How not to Sort an Array In JavaScript
A compare function should be provided when using “Array.prototype.sort()”
The default sort order is alphabetic, rather than numeric, regardless of the types in the array. Specifically, even if an array contains only numbers, all values in it will be converted to strings and sorted lexicographically, for an order like this: 1, 15, 2, 20, 5. Even to sort strings, the default sort order may… Continue reading A compare function should be provided when using “Array.prototype.sort()”
Resolve error ‘hbspt is not defined’ while embedding hubspot script with Suitecommerce
Scenario While using code given below, throwing error ‘hbspt is not defined’. <script charset=”utf-8″ type=”text/javascript” src=”//js.hsforms.net/forms/embed/v2.js”></script> <script> hbspt.forms.create({ region: “na1”, portalId: “23130323”, formId: “22b95edc-a15c-4996-af4c-d32d6650a3a5” }); </script> solution: Change the script to the below format. <script> (() => { const script = document.createElement(“script”); script.setAttribute(“type”, “text/javascript”); script.src =… Continue reading Resolve error ‘hbspt is not defined’ while embedding hubspot script with Suitecommerce
How to avoid timezone offset shift when displaying a date input value in typescript
I was using javascript to show the date field in ‘mm-dd-yyyy’ format from the date input field in typescript. But since the input date value was only having the date and not time, when using the ‘new Date()’ function time was set to 00:00:00 hours GMT. This caused date to shift a day before in… Continue reading How to avoid timezone offset shift when displaying a date input value in typescript
Remove Character Combination from string using JavaScript
To remove a specific character combination from a string in JavaScript, you can use various methods. One way is to use regular expressions with the replace() method. Here’s an example. In this example, the function removeCharacterCombination takes two parameters: ,inputString which is the original string, and combination, which is the character combination you want to… Continue reading Remove Character Combination from string using JavaScript
SuiteScript 2.0 Client Script Debugging
Scenario: I recently ran into a problem where I created a Suitelet that downloaded HTML to include in the page. Next, I wanted to add JavaScript. However, when I went to debug the JavaScript in Chrome it threw an error, but the “Sources” tab in Chrome Dev Tools was blank. I saw the red X,… Continue reading SuiteScript 2.0 Client Script Debugging