Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

console.time js

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

console.time in javascript

// console.time
// This method is used to measure time. For example,
// checking how many seconds it went to complete the x task?


console.time("test");
setTimeout(() => {
    console.timeEnd("test");
}, 1000);


// This will give us the following result:

// test: 1.000s
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 :: javascript detect scroll to bottom of page 
Javascript :: yellowbox react native 
Javascript :: js stop scrolling event 
Javascript :: javascript detect video end 
Javascript :: change hover css javascript 
Javascript :: serve a file in express 
Javascript :: get method 
Javascript :: javascript split by newline 
Javascript :: div outside click event jquery 
Javascript :: javascript sort alphabetically 
Javascript :: change display style onclick 
Javascript :: apache angular routing 
Javascript :: calculate distance between two coordinates formula javascript 
Javascript :: javascript array foreach example 
Javascript :: when I pass a variable as a function parameter, is a new copy of the variable value or a memory reference javascript 
Javascript :: document not intialized react js 
Javascript :: scss mute warnings 
Javascript :: set value of radio button jquery 
Javascript :: logbox ignore warnings 
Javascript :: javascript remove all the common value from array 
Javascript :: next js next/head head 
Javascript :: js remove json value duplicates 
Javascript :: save things javascript 
Javascript :: codewars js Spinning Rings 
Javascript :: regex to remove spaces 
Javascript :: Ckeditor get content html 
Javascript :: how to communicate between nodejs applications 
Javascript :: vscode tab size 
Javascript :: event on input or keydown or on paste value or on change jquery 
Javascript :: enable input jquery 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =