Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JavaScript Object Values

Object.values() is similar to Object.entries(), but it returns a one-dimensional array containing only the values of the object’s properties.

Example

const person = {
  firstName : “John”,
  lastName : “Doe”,
  age : 50,
  eyeColor : “blue”
};

let text = Object.values(person);

The Object.values() method has been supported in all modern browsers since March 2017.

js 12

JavaScript Async Functions

Waiting for a Timeout

async function myDisplay() {
  let myPromise = new Promise(function(myResolve, myReject) {
    setTimeout(function() { myResolve(“I love You !!”); }, 3000);
  });
  document.getElementById(“demo”).innerHTML = await myPromise;
}

myDisplay();

Async functions have been supported in all modern browsers since September 2017.

js 13

JavaScript Trailing Commas

JavaScript allows trailing commas in places where a comma-separated list of values is used, such as in array and object literals, function calls, parameters, imports, and exports.

Example

function myFunc(x,,,) {};
const myArr = [1,2,3,4,,,];
const myObj = {fname: John, age:50,,,};

Trailing commas have been supported in all modern browsers since May 2017.

js 14