Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

console.time js

console.time();
for (i = 0; i < 100000; i++) {
  // some code
}
console.timeEnd();
Comment

console time

console.time();   // Begin timer
// Run code
console.timeEnd();   // End timer and output time
Comment

console.time

console.time("answer time");
alert("Click to continue");
console.timeLog("answer time");
alert("Do a bunch of other stuff...");
console.timeEnd("answer time");
Comment

console.time

console.time('factorial');

const number = 10;
let result = 1;
for (let i = 1; i <= number; i++) {
    result *= i;
    console.timeLog('factorial');
}

console.log('factorial result', result);
console.timeEnd('factorial');
Comment

console.time

const heroes = [
    { name: 'Spiderman', universe: 'Marvel' },
    { name: 'Iron Man', universe: 'Marvel' },
    { name: 'Hulk', universe: 'Marvel' },
    { name: 'Batman', universe: 'DC' },
    { name: 'Superman', universe: 'DC' },
    { name: 'Wonder Woman', universe: 'DC' },
]

const marvel = heroes.filter(h => h.universe === 'Marvel');

console.table(marvel);
Comment

console.time

const heroes = [
    {
        name: 'Spiderman',
        firstName: 'Peter',
        lastName: 'Parker',
        city: 'New York City'
    }, {
        name: 'Iron Man',
        firstName: 'Tony',
        lastName: 'Stark',
        city: 'New York City'
    }];

console.table(heroes);
Comment

console.time

let batman = { name: 'Batman' };
// batman.firstName = "Bruce";
// batman.lastName = "Wayne";
console.log(batman);

batman = { ...batman, firstName: 'Bruce', lastName: 'Wayne' };
console.log(batman);
Comment

console.time

let heroes = [
    ['Superman', 'Batman', 'Wonderwoman'],
    ['Spiderman', 'Iron Man', 'Hulk']
]

console.log(heroes.flat());
Comment

console.time

const numbers = [2, 4, 6, 8];
const multi = numbers.map(n => n * n);
console.log('numbers', multi);
Comment

PREVIOUS NEXT
Code Example
Javascript :: hwo to cehck req header in js 
Javascript :: js read from json 
Javascript :: Putting password in a zip file using node.js 
Javascript :: delete multiple keys from object javascript 
Javascript :: js ceil 
Javascript :: Two different lockfiles found: package-lock.json and yarn.lock 
Javascript :: how do you make a random array in javascript 
Javascript :: discord.js guildMemberAdd 
Javascript :: object.keys 
Javascript :: datatables add row 
Javascript :: nohup run nodejs 
Javascript :: javascript array functions 
Javascript :: jquery get radio button checked 
Javascript :: how to find network there is no network react native 
Javascript :: js is array 
Javascript :: javascript remove underscore and capitalize 
Javascript :: javascript math.pow 
Javascript :: import applymiddleware 
Javascript :: how to use bootstrap icons in react components 
Javascript :: js getelementbyid 
Javascript :: fill an array of zeroes in js 
Javascript :: convert json object to array javascript 
Javascript :: fetching iframe content JS 
Javascript :: first n even numbers sum javascript 
Javascript :: get element class javascript 
Javascript :: JS ignoring accents 
Javascript :: get value of ajax success in variable 
Javascript :: update many mongoose 
Javascript :: Package path ./compat is not exported from 
Javascript :: javascript object tostring 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =