0% found this document useful (0 votes)
9 views

What will the following code log to the console

The document consists of a series of JavaScript code snippets and questions regarding their outputs and behaviors, particularly focusing on variable declarations using var, let, and const. It highlights concepts such as hoisting, scope, and reassignment of constants. Each question requires understanding of JavaScript's variable scoping rules to determine the correct console outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

What will the following code log to the console

The document consists of a series of JavaScript code snippets and questions regarding their outputs and behaviors, particularly focusing on variable declarations using var, let, and const. It highlights concepts such as hoisting, scope, and reassignment of constants. Each question requires understanding of JavaScript's variable scoping rules to determine the correct console outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

 What will the following code log to the console?

javascript

Copy code

console.log(a);

var a = 5;

 What will the following code log to the console?

javascript

Copy code

console.log(b);

let b = 10;

 What is the output of the following code snippet?

javascript

Copy code

function test() {

console.log(c);

let c = 20;

test();

 What will the following code output?

javascript

Copy code

console.log(d);

var d = 30;

 What will the following code log to the console?

javascript

Copy code

console.log(x);

let x = 40;

 What will the following code output?


javascript

Copy code

function example() {

console.log(y);

var y = 50;

example();

 What does the following code do?

javascript

Copy code

var z = 60;

function myFunc() {

console.log(z);

var z = 70;

myFunc();

 What will the following code log?

javascript

Copy code

console.log(a);

let a = 80;

 What is the output of this code?

javascript

Copy code

const p = 90;

p = 100;

console.log(p);

 What will this code log?

javascript

Copy code

console.log(n);
let n = 110;

 What will the following code log to the console?

javascript

Copy code

function testScope() {

if (true) {

var m = 120;

let n = 130;

console.log(m);

console.log(n);

testScope();

 What will this code output?

javascript

Copy code

let o = 140;

function myFunc() {

console.log(o);

let o = 150;

myFunc();

 What will this code print?

javascript

Copy code

console.log(a);

const a = 160;

 What is the output of the following?

javascript

Copy code

function foo() {
console.log(x);

if (true) {

var x = 170;

foo();

 What will the following code output?

javascript

Copy code

console.log(y);

let y = 180;

 What does the following code do?

javascript

Copy code

function test() {

var z = 190;

if (true) {

let z = 200;

console.log(z);

test();

 What will be the result of this code?

javascript

Copy code

console.log(b);

var b = 210;

 What will this code log?

javascript

Copy code

let v = 220;
function myFunc() {

console.log(v);

let v = 230;

myFunc();

 What is the output of the following code?

javascript

Copy code

const x = 240;

x = 250;s

console.log(x);

 What will the following code print?

javascript

Copy code

function outer() {

let x = 260;

function inner() {

console.log(x);

inner();

outer();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy