L8V2L Posted June 29, 2014 Share Posted June 29, 2014 What is html data-*? How is it a improvement for js dev? How can one use it? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 30, 2014 Share Posted June 30, 2014 If you're talking about attributes, data attributes are a standard supported way to add additional data to an element, rather than trying to fit data into an existing set of attributes that don't match what the actual data is. 1 Link to comment Share on other sites More sharing options...
L8V2L Posted June 30, 2014 Author Share Posted June 30, 2014 If you're talking about attributes, data attributes are a standard supported way to add additional data to an element, rather than trying to fit data into an existing set of attributes that don't match what the actual data is.So in lamen terms, it just away to make your own attribute.(please a yes or no for clarity)Is that all it's go for? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 30, 2014 Share Posted June 30, 2014 That's what it's for, yes. In previous versions of HTML, adding your own attributes would cause validation to fail. 1 Link to comment Share on other sites More sharing options...
L8V2L Posted June 30, 2014 Author Share Posted June 30, 2014 That's what it's for, yes. In previous versions of HTML, adding your own attributes would cause validation to fail.Thank you for clairty! :-)... Can I alter it with js to make it an event then js a static key value pair? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 30, 2014 Share Posted June 30, 2014 I don't understand your question. Link to comment Share on other sites More sharing options...
L8V2L Posted July 1, 2014 Author Share Posted July 1, 2014 I don't understand your question.Can I alter it with js to make it more than just a storage for data? Can I turn it into an event? Can I assign it a function that will expand it's functionality? Making it more than just a static data storage for holding value? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 1, 2014 Share Posted July 1, 2014 You can't create a new attribute and have it automatically treated as an event handler without writing all of the code to monitor elements and set up those handlers. Ideally, if you are creating event handlers then you use Javascript to attach those events instead of putting them in HTML attributes. You can create custom events and manually dispatch them on specific elements.http://www.sitepoint.com/javascript-custom-events/ 1 Link to comment Share on other sites More sharing options...
L8V2L Posted July 1, 2014 Author Share Posted July 1, 2014 You can't create a new attribute and have it automatically treated as an event handler without writing all of the code to monitor elements and set up those handlers. Ideally, if you are creating event handlers then you use Javascript to attach those events instead of putting them in HTML attributes. You can create custom events and manually dispatch them on specific elements.http://www.sitepoint.com/javascript-custom-events/Thanks for the link! :-) I like your post for two reason. One, is to show my appreciation. And two is in the hope of this forums allowing it's user to browse by likes. So I can reference this again. Link to comment Share on other sites More sharing options...
L8V2L Posted July 2, 2014 Author Share Posted July 2, 2014 JSG, could you give me your knowledge on prototype and constructor function?I have question, but it's more of a discussion then a straight out asking manner.If anyone would like to do the same Davej, and the others, you are more than welcome to do so. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 2, 2014 Share Posted July 2, 2014 JSG, could you give me your knowledge on prototype and constructor function?Uhh.. not really. I have a job you know, I'm not just sitting here posting on a forum all day. If you have specific questions I can try to address them. I'm not going to sit here and type out an entire tutorial though. Link to comment Share on other sites More sharing options...
L8V2L Posted July 2, 2014 Author Share Posted July 2, 2014 (edited) Uhh.. not really. I have a job you know, I'm not just sitting here posting on a forum all day. If you have specific questions I can try to address them. I'm not going to sit here and type out an entire tutorial though.x-p <== addresses that! Edited July 2, 2014 by L8V2L Link to comment Share on other sites More sharing options...
L8V2L Posted July 2, 2014 Author Share Posted July 2, 2014 Do anyone have a suggestion for an xml book?! Link to comment Share on other sites More sharing options...
justsomeguy Posted July 2, 2014 Share Posted July 2, 2014 Asking the same question more than once isn't going to get different answers. Link to comment Share on other sites More sharing options...
L8V2L Posted July 2, 2014 Author Share Posted July 2, 2014 Asking the same question more than once isn't going to get different answers.You're absolutely right. Just got me a unhelpful response. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 2, 2014 Share Posted July 2, 2014 If anyone cares to give you a helpful response, they will do so regardless of where your question is. Notwithstanding the fact that you're asking about XML books in a Javascript thread that doesn't have anything to do with XML. Link to comment Share on other sites More sharing options...
L8V2L Posted July 2, 2014 Author Share Posted July 2, 2014 If anyone cares to give you a helpful response, they will do so regardless of where your question is. Notwithstanding the fact that you're asking about XML books in a Javascript thread that doesn't have anything to do with XML.No one be in the xml thread.... But I'll try. Link to comment Share on other sites More sharing options...
L8V2L Posted July 4, 2014 Author Share Posted July 4, 2014 shadowing variables, what it mean? :-) Link to comment Share on other sites More sharing options...
justsomeguy Posted July 7, 2014 Share Posted July 7, 2014 http://en.wikipedia.org/wiki/Variable_shadowing 1 Link to comment Share on other sites More sharing options...
L8V2L Posted July 9, 2014 Author Share Posted July 9, 2014 (edited) Why does it stack over flow when condition is taking out: var bar = function(num){ return (num + arguments.callee(num - 1));}var result = bar(2);console.log(result);//stack exceededvar foo = function(bar){ if(bar < 0){ return -1; } else if(bar === 0){ return 1;} else{ return(bar + arguments.callee(bar - 1)); }}foo(2);// output 4Extra:var bar = function(args) { var err;var actual = arguments.length; var expected = arguments.callee.length; switch(actual != expected){ case true:{throw err = new Error("Wrong number of arguments: expected: " + expected + "; actually passed " + actual); break;}case false:{if(arguments[0] < 0){ return -1;}else if(arguments[0] === 0){return 1;}else{return (arguments[0] * arguments.callee(arguments[0] -1));break;}}}}bar(99); Edited July 9, 2014 by L8V2L Link to comment Share on other sites More sharing options...
justsomeguy Posted July 9, 2014 Share Posted July 9, 2014 Why wouldn't it overflow the stack? What are you telling it to do? Think about it. Link to comment Share on other sites More sharing options...
L8V2L Posted July 9, 2014 Author Share Posted July 9, 2014 Why wouldn't it overflow the stack? What are you telling it to do? Think about it.If I put a if else condition in to check for 1, 0 or less, It'll work. Why is that?I display this happening with two of the same code, but with just different names. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 9, 2014 Share Posted July 9, 2014 If I put a if else condition in to check for 1, 0 or less, It'll work. Why is that?Look at the code, what does it do with the check? What does it do without it? Link to comment Share on other sites More sharing options...
L8V2L Posted July 9, 2014 Author Share Posted July 9, 2014 Look at the code, what does it do with the check? What does it do without it?So why don't it return 1? Or if I was decrementing by a value higher than one, why don't it return -1?Why do it return the value of the expression? (Even know expression evaluate to a value) when it recursion by invoking it self, shouldn't it return 1, or -1 if decrementing by a numeral value higher than 1. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 9, 2014 Share Posted July 9, 2014 So why don't it return 1? Or if I was decrementing by a value higher than one, why don't it return -1?You need to trace the code. Use a pencil and paper if you need to. What are you telling the function to return? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now