Reader small image

You're reading from  Hands-on JavaScript for Python Developers

Product typeBook
Published inSep 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838648121
Edition1st Edition
Tools
Right arrow
Author (1)
Sonyl Nagale
Sonyl Nagale
author image
Sonyl Nagale

Chicago-born, Iowa-raised, Los Angeles-seasoned, and now New York City-flavored, Sonyl Nagale started his career as a graphic designer focusing on web, which led down the slippery slope to becoming a full-stack technologist instead. With an eye toward the client use case and conversation with the creative side, he prides himself on taking a holistic approach to software engineering. Having worked at start-ups and global media companies using a variety of languages and frameworks, he likes solving new and novel challenges. Passionate about education, he's always excited to have great teachable moments complete with laughter and seeing the Aha! moments in students eyes.
Read more about Sonyl Nagale

Right arrow

Questions

Consider the following code:

function someFunc() {
let bar = 1;

function zip() {
alert(bar); // 1
let beep = 2;

function foo() {
alert(bar); // 1
alert(beep); // 2
}
}

return zip
}


function sayHello(name) {
const sayAlert = function() {
alert(greeting)
}

const sayZip = function() {
someFunc.zip()
}

let greeting = `Hello ${name}`
return sayAlert
}
  1. How would you get an alert of Hello Bob?
    1. sayHello()('Bob')
    2. sayHello('Bob')()
    3. sayHello('Bob')
    4. someFunc()(sayHello('Bob'))
  2. What will alert(greeting) do in the preceding code?
    1. Alert greeting.
    2. Alert Hello Alice.
    3. Throw an error.
    4. None of the above.
  3. How would we get an alert message of 1?
    1. someFunc()()
    2. sayHello().sayZip()
    3. alert(someFunc.bar)
    4. sayZip()
  4. How would we get an alert message of 2?
    1. someFunc().foo().
    2. someFunc()().beep.
    3. We can't because it's not in the scope.
    4. We can't because it's not defined.
  5. How can we change someFunc to alert...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-on JavaScript for Python Developers
Published in: Sep 2020Publisher: PacktISBN-13: 9781838648121

Author (1)

author image
Sonyl Nagale

Chicago-born, Iowa-raised, Los Angeles-seasoned, and now New York City-flavored, Sonyl Nagale started his career as a graphic designer focusing on web, which led down the slippery slope to becoming a full-stack technologist instead. With an eye toward the client use case and conversation with the creative side, he prides himself on taking a holistic approach to software engineering. Having worked at start-ups and global media companies using a variety of languages and frameworks, he likes solving new and novel challenges. Passionate about education, he's always excited to have great teachable moments complete with laughter and seeing the Aha! moments in students eyes.
Read more about Sonyl Nagale