Some basic tips for JavaScript Beginners

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

1. Place Scripts at the Bottom of Your Page

For a better page loading as quickly as possible. It is good to place the script files at the bottom of your page before closing the body tag. Like @copyright <script type=”text/javascript” src=”example_file1.js”></script> <script type=”text/javascript” src=”example_file1.js”></script> It’s also good if you create a separate file for your custom JavaScript code instead putting that code in header or in the bottom section of the page. Like <script> function abc() { // your code } function anotherfunction() { // your code } </script> Better: Create a separate file for this code such as “custom.js” and include it in the page.

2. Use === Instead of ==

JavaScript utilizes two different types of equality operators: === | !== and == | != . For best practice it is always good to use the former set when comparing. If you compare two operands of the same type and value, then “===” produces true and “!==” produces false. However, when working with “==” and “!=” it will just compare the values only and not the type and will run you into issues when working with different types.

3. Comment Your Code

It might seem unnecessary and waste of time at first, but, It’s good to comment your code- as best as possible. Sometimes, you have to make a few changes in your code and it could be after a month or later, then there is only one way to remember what your line of code was a month before and that’s with the help of comments. And, It not only helps you in remembering the code but also your colleagues who need to revise your code. So, it is suggested to comment the important part of your code regularly. For Example: // Script for DatePicker jQuery(‘#datePicker’) .datepicker({ format: ‘mm/dd/yyyy’ })

4. Use [] Instead of New Array()

The same principle is applicable for creating a new array. The code below is Okay var a = new Array(); a[0] = “Red”; b[1] = “Blue”; But the Better Way is var a = [‘Red’,”Blue”]; “A common error in JavaScript programs is to use an object when an array is required or an array when an object is required. The rule is simple: when the property names are small sequential integers, you should use an array. Otherwise, use an object.” – Douglas Crockford

5. Long List of Variables? Omit the "Var" Keyword and Use Commas Instead

If you have a long list of variables Like var variable1 = “some string”; var variable2 = “another string”; var variable3 = “one more string”; then use the comma after every new variable instead defining it again like: var variable1 = “some string”, variable2 = “another string”, variable3 = “one more string”; It will cleanup your code.

6. Always, Always Use Semicolons

Technically, most browsers will allow you to get away with omitting semicolons. Like: var newvariable = “some string” function anyfunction() { return “something” } this is a very bad practice that can potentially drag you to a much bigger, and harder effort for finding issues. So, the Better Way is var newvariable = “some string”; function anyfunction() { return “something”; }

There has been a lot of focus on user interfaces nowadays. They have to be snappy, media responsive, and beautiful at the same time. With projects like polymer and web components, google introduced the idea to build reusable components....
What are Wireframes in Website Design? Many of us must have heard the term “wireframe” while working with web designers. However, many people aren’t aware of benefits of wireframing and what does this mean for their web presence. Wireframing is quick and an effective way of identifying usability issues early on in the design process. Let us learn more about what are wireframes in website design? What is a wireframe design? You can call it a platform where a client and the web experts sit together to understand the informational hierarchy of a webpage. So, it becomes easier to plan the […]...
Even if you haven’t had the opportunity to use a cab service ever, I’m sure you must have heard about Uber. For those living under the rock, it is a car/ taxi booking app that you can use on your computer or mobile phone on the go.....