I have a constructor function which registers an event handler:    function MyConstructor(data, transport) {     this.data = data;     transport.on('data', function () {         alert(this.data);     }); }  // Mock transport object var tran...
Given the following examples, why is outerScopeVar undefined in all cases?  var outerScopeVar;  var img = document.createElement('img'); img.onload = function() {     outerScopeVar = this.width; }; img.src = 'lolcat.png'; alert(oute...
I have a nested data structure containing objects and arrays. How can I extract the information, i.e. access a specific or multiple values (or keys)?  For example:  var data = {     code: 42,     items: [{         id: 1,         name: 'foo'...
What are the possible reasons for document.getElementById, $("#id") or any other DOM method / jQuery selector not finding the elements?  Example problems include:   jQuery silently failing to bind an event handler jQuery "getter" me...
I have this code:  <script type="text/javascript">     var foo = 'bar';     <?php         file_put_contents('foo.txt', ' + foo + ');     ?>      var baz = <?php echo 42; ?>;     alert(baz); </scr...
Is there a plugin-less way of retrieving query string values via jQuery (or without)?   If so, how? If not, is there a plugin which can do so?...
I was writing code that does something that looks like:  function getStuffDone(param) {           | function getStuffDone(param) {     var d = Q.defer(); /* or $q.defer */ |     return new Promise(function(resolve, reject) {     // or = new $.Defer...
What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally?...
Do getElementsByClassName (and similar functions like getElementsByTagName and querySelectorAll) work the same as getElementById or do they return an array of elements?  The reason I ask is because I am trying to change the style of all elements us...
I've been told not to use for...in with arrays in JavaScript. Why not?...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.