1let str = "12345.00";
2str = str.substring(0, str.length - 1);
3console.log(str);
1// The usual way of writing function
2const magic = function() {
3 return new Date();
4};
5
6// Arrow function syntax is used to rewrite the function
7const magic = () => {
8 return new Date();
9};
10//or
11const magic = () => new Date();
12
13
1const person = {
2 firstName: 'Viggo',
3 lastName: 'Mortensen',
4 fullName: function () {
5 return `${this.firstName} ${this.lastName}`
6 },
7 shoutName: function () {
8 setTimeout(() => {
9 //keyword 'this' in arrow functions refers to the value of 'this' when the function is created
10 console.log(this);
11 console.log(this.fullName())
12 }, 3000)
13 }
14}
1//Normal function
2function sum(a, b) {
3 return a + b;
4}
5
6//Arraw function
7let sum = (a, b) => a + b;