This site is mobile accessible. Press the "Tap Here" button to use a different font-size.
Smartphone icons created by Freepik - Flaticon
A membership with W3SCHOOLS.COM are required to access the links below.
let text1 = " Hello World! "; let text2 = text1.trimStart();
JavaScript String
is supported in all modern browsers since January 2020:![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Chrome 66 | Edge 79 | Firefox 61 | Safari 12 | Opera 50 |
Apr 2018 | Jan 2020 | Jun 2018 | Sep 2018 | May 2018 |
let text1 = " Hello World! "; let text2 = text1.trimEnd();
JavaScript String
is supported in all modern browsers since January 2020:![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Chrome 66 | Edge 79 | Firefox 61 | Safari 12 | Opera 50 |
Apr 2018 | Jan 2020 | Jun 2018 | Sep 2018 | May 2018 |
const fruits = [ ["apples", 300], ["pears", 900], ["bananas", 500] ]; const myObj = Object.fromEntries(fruits);
JavaScript Object
is supported in all modern browsers since January 2020:![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Chrome 73 | Edge 79 | Firefox 63 | Safari 12.1 | Opera 60 |
Mar 2019 | Jan 2020 | Oct 2018 | Mar 2019 | Apr 2019 |
From ES2019 you can omit the catch parameter if you don't need it:.
Before 2019:
try { // code } catch (err) { // code }
After 2018
try { // code } catch { // code }
Optional catch binding is supported in all modern browsers since January 2020
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Chrome 66 | Edge 79 | Firefox 58 | Safari 11.1 | Opera 53 |
Apr 2018 | Jan 2020 | Jan 2018 | Mar 2018 | May 2018 |
const myArr = [[1,2],[3,4],[5,6]]; const newArr = myArr.flat();
JavaScript Array
is supported in all modern browsers since January 2020:![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Chrome 69 | Edge 79 | Firefox 62 | Safari 12 | Opera 56 |
Sep 2018 | Jan 2020 | Sep 2018 | Sep 2018 | Sep 2018 |
const myArr = [1, 2, 3, 4, 5, 6]; const newArr = myArr.flatMap((x) => x * 2);
const myArr = [ {name:"X00",price:100 }, {name:"X01",price:100 }, {name:"X02",price:100 }, {name:"X03",price:100 }, {name:"X04",price:110 }, {name:"X05",price:110 }, {name:"X06",price:110 }, {name:"X07",price:110 } ];
In the example above, when sorting on price, the result is not allowed to come out with the names in an other relative position like this:
X01 100 X03 100 X00 100 X03 100 X05 110 X04 110 X06 110 X07 110
let text = JSON.stringify("\u26D4");
// This is valid in ES2019: let text = "\u2028";
function myFunction(p1, p2) { return p1 * p2; }
Eventually the navigation links, above, will be replaced by these (previous) and (next) buttons below.
JavaScript icons used in the buttons provided by ICONS8.COM. Smartphone icons created by Freepik - Flaticon