Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 06/08/2018 in all areas

  1. 1 point
    Again, the second one does not work because you have defined the function inside a limited scope. It is not available in the scope where the click event on that button executes. Everything in Javascript executes inside a specific scope. By default, the scope is the window object. That's why you can refer to window.alert, window.prompt, window.location etc without needing to preface it with the window object, because that's the default scope. You have defined the function inside a non-global scope, so it is not defined globally. Conversely, when you modify the prototype of any object, there's only one prototype. Prototypes are not defined in some scope but not others, they are always global, so no matter where you make changes to a prototype it will always affect every instance of that object. Let me be super explicit: if you want to show your complete code, without removing anything that you're assuming is not the problem, then I will just tell you what changes to make and why that fixes it.
  2. 1 point
    It does not accept String() within function parentheses.
×