September 19, 201511 yr introduction Well Hello Every One $myNameis = Mohammed ; // Im From Algeria And Today I joined This Awesome Forum Hoping That I can Help Others , Give Tutorials and Discuss some design topics with all Of You i'm also on twitter under @dzstormers
September 19, 201511 yr introduction Well Hello Every One $myNameis = Mohammed ; // Im From Algeria And Today I joined This Awesome Forum Hoping That I can Help Others , Give Tutorials and Discuss some design topics with all Of You i'm also on twitter under @@dzstormers Its a catchy intro but $myNameis needs a datatype of string passed to it like $myNameis = "Mohammed";
September 19, 201511 yr Author Its a catchy intro but $myNameis needs a datatype of string passed to it like $myNameis = "Mohammed"; God I don't believe that i forget quotes after 3 years in javascript
September 19, 201511 yr You say this is JavaScript but.. Why are you prepending your variable name with a $ if your code is JavaScript? The convention being that a variable prepended with $ is a jQuery object - so in this instance is a potential for confusion. You also have not put a var statement, which will return an error in strict mode / make it a global in non-strict. My take from it is that you are mixing up PHP with JavaScript. Or where you meant to say 3 years in PHP? I'm confused. Edited September 19, 201511 yr by rbrtsmith
September 19, 201511 yr Welcome to WDF Mohammed. The only forum in the world with build in (human) error reporting
September 20, 201511 yr You say this is JavaScript but.. Why are you prepending your variable name with a $ if your code is JavaScript? The convention being that a variable prepended with $ is a jQuery object - so in this instance is a potential for confusion. You also have not put a var statement, which will return an error in strict mode / make it a global in non-strict. My take from it is that you are mixing up PHP with JavaScript. Or where you meant to say 3 years in PHP? I'm confused. God I don't believe that i forget quotes after 3 years in javascript This is PHP buddy javascript would look like the below either way welcome to the forum var myName = "Steve"; Edited September 20, 201511 yr by webdesigner93
September 20, 201511 yr Badly written JavaScript would still work like the OP put - I've seen it on a few projects I've inherited in the past. Global hell.
September 20, 201511 yr Author well im a php dev from along time ago , then i moved to javscript i studied making frameworks with ecmascript then you know i get to a point where i liked Jquery More Then Javascript so im kind of stuck now between Jquery Hml5 And css some Times Php And Laravel
September 20, 201511 yr Author Welcome to WDF Mohammed. The only forum in the world with build in (human) error reporting God I Start To Love This Forum SO Responsive hhhhhhhhhhhhhhhhhhhh
September 20, 201511 yr jQuery is JavaScript. it's just a JavaScript function that abstracts over the horrible DOM API. What frameworks did you work on? Are they on GitHub? Edited September 20, 201511 yr by rbrtsmith
September 20, 201511 yr Author no just beta testing , i was trying to get my own personal set of helpers methods instead of using jquery , i even searched in a lot of books , but you know Jquery is more powerful and robust and this kind of what i was doing /* * The Event Utility Object */ var EventUtil = { //This Method Is Used To Assigne Handler To Element addHandler: function(element, type, handler){ if (element.addEventListener){ element.addEventListener(type, handler, false); } else if (element.attachEvent){ element.attachEvent("on" + type, handler); } else { element["on" + type] = handler; } }, //This Method Is Used To Get The Event Object getEvent: function(event){ return event ? event : window.event; }, //This Method Is Used TO Get The Event Target getTarget: function(event){ return event.target || event.srcElement; }, //This Method Is Used To Prevent The Defautl Behavior preventDefault: function(event){ //This Is A Cross Browser Compatible if (event.preventDefault){ //DOM Compilant Browsers event.preventDefault(); } else { //IE Browsers event.returnValue = false; } }, //This Method Is Used To Remove A handler removeHandler: function(element, type, handler){ //This Is A Cross Browser Compatible if (element.removeEventListener){ element.removeEventListener(type, handler, false); } else if (element.detachEvent){ element.detachEvent("on" + type, handler); } else { element["on" + type] = null; } }, //This Method Is Used To Stop The Bubbling Phase stopPropagation: function(event){ //This Is A Cross Browser Compatible if (event.stopPropagation){ //DOM Compilant Browsers event.stopPropagation(); } else { //IE Browsers event.cancelBubble = true; } }, getRelatedTarget: function(event){ if (event.relatedTarget){ return event.relatedTarget; } else if (event.toElement){ return event.toElement; } else if (event.fromElement){ return event.fromElement; } else { return null; } } }; /** * GFX Effects */ sp.show = function(obj) { obj.style.display = ""; } sp.hide = function(obj) { obj.style.display = "none"; } /** * Validation */ sp.empty = function(value) { if(value == "" || value == null || value == false) { return true; } return false; } // Document DOM Ready (DOM READY); sp.run = function(obj) { // Firefox & Opera if (sp.browser() == "Firefox" || sp.browser() == "Opera" || sp.browser() == "Chrome") { d.addEventListener("DOMContentLoaded", function() { sp.called = true; obj.init; }, false); } // Internet Explorer else if (sp.browser() == "IE" && sp.browser() != "Opera"){ d.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>'); var contentloadtag = d.getElementById("contentloadtag"); contentloadtag.onreadystatechange = function(){ if (this.readyState=="complete"){ sp.called = true; obj.init; } } } // Safari & Chrome else if (sp.browser() == "Safari") { var timer = setInterval(function() { if (/loaded|complete/.test(d.readyState)) { sp.called = true; clearInterval(timer); obj.init; } }, 10); } // Other browsers // called is a property that has been intialized to achive the trace of the called method // in a documentready event if(!sp.called) { sp.bind(w, "load", obj.init, false); } }; jQuery is JavaScript. it's just a JavaScript function that abstracts over the horrible DOM API. What frameworks did you work on? Are they on GitHub? Edited September 20, 201511 yr by dzstormers
September 21, 201511 yr Yes jQuery abstracts over a the browser differences, they're nowhere near as bad now, but there are still differences that can catch you out unless you test heavilly - which takes time. The never use jQuery brigade are missing a trick and are often prematurely optimising. 30kb minified and Gzipped is not gonna kill your performance - of course it's unecessary to use if you are doing some basic stuff but you have to weigh things up. It is also possible to do custom jQuery builds too with NPM to keep the filesize down. No jQuery: Pros - smaller file size. Cons - More time to write, test, chances of bugs is higher, harder for other devs to maintain. You have to weigh up these things on a project and decide whether or not jQuery is a welcome addition. Let's face it, the DOM API isn't great and it's nice to abstract that badness away into something more human readable. The argument of learning JavaScript properly is true. But that doesn't mean doing everything in the native DOM API, it means learning about how to actually use the language, understanding functions, closure, prototypes etc. Edited September 21, 201511 yr by rbrtsmith
September 21, 201511 yr Author Yes jQuery abstracts over a the browser differences, they're nowhere near as bad now, but there are still differences that can catch you out unless you test heavilly - which takes time. The never use jQuery brigade are missing a trick and are often prematurely optimising. 30kb minified and Gzipped is not gonna kill your performance - of course it's unecessary to use if you are doing some basic stuff but you have to weigh things up. It is also possible to do custom jQuery builds too with NPM to keep the filesize down. No jQuery: Pros - smaller file size. Cons - More time to write, test, chances of bugs is higher, harder for other devs to maintain. You have to weigh up these things on a project and decide whether or not jQuery is a welcome addition. Let's face it, the DOM API isn't great and it's nice to abstract that badness away into something more human readable. The argument of learning JavaScript properly is true. But that doesn't mean doing everything in the native DOM API, it means learning about how to actually use the language, understanding functions, closure, prototypes etc. You Right mate lets face it , Jquery is Awesome
September 21, 201511 yr It is, but it annoys me when people are using it for things that have nothing to do with the DOM. Stack overflow is full of answers using jQuery for things like manipulating arrays and objects - that's not how it should be used. Lodash is a good lightweight library if you wanna be abstracting parts of the language away.
September 21, 201511 yr Author It is, but it annoys me when people are using it for things that have nothing to do with the DOM. Stack overflow is full of answers using jQuery for things like manipulating arrays and objects - that's not how it should be used. Lodash is a good lightweight library if you wanna be abstracting parts of the language away. Of Course , I Think Most People have wrong idea about Jquery They think it is another language, in the other hand they think that javascript is complicated and error prone, Jquery is just A wrapper For Js
September 22, 201511 yr I'd agree with them that JavaScript is complicated. The main reasons they find it to be error prone are: Don't bother to learn it, so attempt to build constructs in the same way as they would with other languages like Java. The DOM. The terrible DOM API is not JavaScript's fault, it would be just as bad with any other language. Because they don't learn the language they try to use block scope, don't understand variable hoisting, The == operator does not type check, try to use classes. etc.. It's like me saying the Swedish language is inferior because I cannot speak it fluently. Many programmers do not like change, I think this is a primary reason why many are still convinced that classical inheritance is a good thing. Crockford refers to 'class' as the new 'goto' as it took so long to phase out goto - because developers couldn't imagine life without it. Edited September 22, 201511 yr by rbrtsmith
Create an account or sign in to comment