google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Conseils simples pour apprendre JavaScript mieux pour les d?butants Ce JavaScript tutorial va nous montrer quelques JavaScript conseils et astuces, des solutions simples et pratiques JavaScript JavaScript pour les d?butants d'apprendre le langage de programmation JavaScript mieux Cet article est essentiellement ?crite pour D?marreurs JavaScript mais il contient encore de nombreux utile R?f?rences JavaScript pour tous les codeurs JavaScript , les d?veloppeurs web S'il vous pla?t aller ? la page post complet pour plus de d?tails et des exemples de code JavaScript
JavaScript Form Validating Tips, Code and Examples

? 5 habitudes JavaScript Bon pour une meilleure am?lioration

? 10 extraits de code JavaScript Tiny pour les d?butants bonne

? Top 10 Meilleurs livres JavaScript que les d?butants devraient apprendre

? Les bases de Javascript pour les d?butants


G�n�rez vos vid�os d'entreprise par l'IA avec la voix ou simplement du texte



Votre premi�re application vid�o AI GRATUITE ! Automatisez votre premi�re vid�o AI. Cr�ez votre vid�o professionnelle en 5 minutes gr�ce � l'IA. Aucun �quipement ni comp�tence en montage vid�o requis. Production vid�o sans effort pour les sp�cialistes du marketing de contenu.
Application vid�o AI ILLIMIT�E gratuite � port�e de main

Follow the DOM, not the Sizzle

After several months of regularly using jQuery and Dojo I’ll now be returning to core JavaScript in 2011 and incorporating that into my code wherever possible.

Essentially, jQuery is a series of functions. It is important to understand that it is not there to replace JavaScript, but it is an aid to using it more quickly and effectively. Understand and use raw JavaScript first, and rely on jQuery or one of the other existing projects next if you must.

In jQuery this is how you would find a div with an id

1
var exampleId = jQuery(#example);

While in DOM JavaScript it is:

1
var exampleId = document.getElementById(example);

Use the DOM object method wherever possible and don’t pass it through a function unless it is necessary to do so.

There is some criticism that JavaScript libraries carry too much code bloat, but by using the DOM and the JS core you minimise this issue.

In a similar spirit, I also use the core JavaScript loops and arrays rather than anything provided by jQuery. The point is to use a library, but don’t be dependent on it. For that you’ll need to understand the differences and then make decisions about when is the appropriate moment to use a somebody else’s script, and when you shouldn’t.

There is though one good reason why you should go through all the pain of forsaking jQuery and tackling JavaScript without an aid and that is because it will make you immensely employable.

You quite likely to be head hunted by an agency if you have advanced JavaScript experience as it is a skillset that is currently much in demand, and it would be fair to forecast the future and state that JavaScript will become an increasingly dominant web technology in coming years, rather than a shrinking one.

Try to Use Object Detection, not Browser Sniffing

Even with the best equipped JavaScript library, you will still regularly run into issues with IE that needs special attention.

If the JavaScript is used for non-essential eye candy, it may well be the best option to forget about IE 6 or 7 by creating a conditional statement that blocks both or either of these browsers from using the code. After all, time is money � and you have your sanity to worry about.

It is possible to detect the make and version number of a browser but the code to do so can be unreliable; indeed, jQuery have recommended against its use. A more trustworthy alternative is to use object detection.

jQuery has a limited set of object detection based around support, but Modernizr is a well-loved and well-respected script.

An example of Modernizr in action. The code below tests of HTML local.storage.

1
2
3
4
5
6
7
8
9
if (Modernizr.localstorage){

 
// For browers Chrome 4+; Firefox 3.5+; IE8+; Opera 10.5+; Safari 4+; plus iPhone 2.0+; and Android 2.0+.
 
} else {
 
// Use cookies for all the others
 
}

This is the code I use to run JS in any browser apart from Internet Explorer 6:

1
2
3
4
5
if (document.documentElement && typeof document.documentElement.style.maxHeight != "undefined") {

 
// code here
 
}

JavaScript purists might have little fit at the above slice of code as they consider objects should only be used for the object it is testing for, but you are never going to have perfection when comes to Internet Explorer.

Use JSLint

JSLint is kind of like a JavaScript validator, or a a code quality tool as it is described on their website. If you are new to this script and are wondering why your code isn’t working then cut and paste it into JSLint and let the automatically generated suggestions help you debug your work.

Even a single wrongly placed comma can stop the whole script from running, especially in IE which is a lot less tolerant of mistakes.

Keep your Code Tidy and Use Comments

If you write JavaScript without explaining your code you are either a complete arsehole (because you couldn’t care less about the developer after you) or you are a masochist, because when you return to your code a few months later it will be difficult to understand.

Use comments liberally. It is better to have too many comments then too few, at least then you can delete unnecessary comments at the end of the job (refactoring comments?!).

In JavaScript there are two different ways to leave comments. They are:

1
2
3
4
5
// This is a single line comment
 
/*
This is a block of comments
*/

Likewise keep your code need and tidy and you can do that by using the rather wonderful JSBeautifier. This will indent your code into an easy to read pattern.

Also, I have now started to add a dollar sign to my variables akin to PHP. Unlike in PHP, there is no such requirement in JavaScript but nevertheless I find it easier on the eye when quickly scanning a document.

Conclusion

JavaScript with the DOM bumps mentioned above can be both infuriating and frustrating. But, like anything else, persistence pays off � and you may even grow to quite like the cantankerous old bugger.

One thing for sure though is that JavaScript is a key web technology of the present and the future. You ignore it at your peril. So buy some books, watch some Think Vitamin tutorials and get coding!

If you have any recommendations for JavaScript newbies that builds on this article, whether books, guides or techniques – then please post them below.

AIVideo-App.com
Générez vos vidéos d'entreprise par l'IA avec la voix ou simplement du texte

chatGPTaz.com
Parlez à ChatGPT dans votre langue maternelle

AppAIVidéo
Votre première application vidéo AI GRATUITE

Deepfake Video
Deepfake AI Video Maker

Deepfake
Deepfake AI Video Maker

AI Deep Fake
Deepfake AI Video Maker

AIvidio
AI Video Mobile Solutions

AIvideos
AI Video Platform & Solutions

AIvedio
AI Video App Maker

Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)

Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)

Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT

Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT

Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT

Powerful AI Presentation PPT Maker for FREE
Build an impressive presentation with our free online AI presentation app

Your next top AI Assistant
Claude AI, developed by Anthropic

Your next top AI Assistant
Claude AI, developed by Anthropic

Temu gratuit 500 $ pour les nouveaux utilisateurs
Claim Free Temu $500 Credit via Affiliate & Influencer Program

Crédits publicitaires TikTok gratuits
Maîtrisez les publicités TikTok pour le marketing de votre entreprise

Dall-E-OpenAI.com
Générez automatiquement des images créatives avec l'IA

chatGPT4.win
Parlez à ChatGPT dans votre langue maternelle

Premier produit d'intelligence artificielle d'Elon Musk - Grok/UN.com
Parlez au chatbot Grok AI dans votre langue

Outily.win
Centre d'outils ouvert et gratuit, utilisable par tous et pour tous, avec des centaines d'outils

GateIO.gomymobi.com
Airdrops gratuits à réclamer et à partager jusqu'à 150 000 $ par projet

iPhoneKer.com
Économisez jusqu'à 630 $ à l'achat d'un nouvel iPhone 16

Acheter le robot Tesla Optimus
Commandez votre robot Tesla Bot : Optimus Gen 2 dès aujourd'hui pour moins de 20 000 $

JavaScript par jour


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web