Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Enhanced object literals in ES6

const color = 'red'
const point = {
  x: 5,
  y: 10,
  color,
  toString() {
    return 'X=' + this.x + ', Y=' + this.y + ', color=' + this.color
  },
  [ 'prop_' + 42 ]: 42
}

console.log('The point is ' + point)
console.log('The dynamic property is ' + point.prop_42)
Comment

PREVIOUS NEXT
Code Example
Javascript :: Find the count of a letter in a string 
Javascript :: reduce javascript 
Javascript :: autocomplete html in react 
Javascript :: js code for webpage download progress bar 
Javascript :: bind in javascript example 
Javascript :: redirect to another path react 
Javascript :: / w/g in javascript 
Javascript :: javascript if return true false 
Javascript :: pass a variable by reference to arrow function 
Javascript :: prisma database example 
Javascript :: readline nodejs 
Javascript :: how to compile typescript to javascript es6 
Javascript :: how to remove the last value of javascript array 
Javascript :: js test library 
Javascript :: chrome-aws-lambda 
Javascript :: ant design form validation in the modal 
Javascript :: spread operator in js 
Javascript :: update data in sequelize 
Javascript :: js object destructuring 
Javascript :: javascript filter method 
Javascript :: how to add comment in javascript 
Javascript :: javaScript delete() Method 
Javascript :: React useEffect() the side-effect runs after every rendering 
Javascript :: what is bom in javascript 
Javascript :: resolvers in angular 
Javascript :: jquery plugins 
Javascript :: datatable ajax reload 
Javascript :: regex validate email 
Javascript :: add 2 class names react 
Javascript :: react hook from 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =