+ 7

Why JS is loosely typed? Explain with an example.

18th Oct 2018, 7:42 AM
Sin Cos Ø
Sin Cos Ø - avatar
8 Réponses
+ 5
I agree with Lisa F. In the early years of HTML, web pages were quite static in the browser with all logic residing within the web server application. Netscape originally created Javascript as "a 'glue language' that was easy to use by Web designers and part-time programmers to assemble components such as images and plugins, where the code could be written directly in the Web page markup." - Wikipedia (JavaScript) This aligned with a concept at the time known as Dynamic HTML (DHTML) which focused on bringing simple UI/design functionality to web content that was predominantly being built by web designers, who had little to no programming experience. At that time, programmers worked on desktop or server applications. As we have seen, things have changed over the years and now we have large, feature rich, full scale applications written in Javascript that run in browsers, as well as, servers, desktops, and mobile devices.
18th Oct 2018, 6:21 PM
David Carroll
David Carroll - avatar
+ 9
Programming languages can be strong or loose type. Loose type could be prone to errors, developers need a better test functions, but it builds coding more faster and easily. JavaScript can be written in strong type by using Typescript. Some developers especially larger scale application development or angular developers use Typescript to write codes.
18th Oct 2018, 11:13 AM
Calviղ
Calviղ - avatar
+ 7
My impression was that it is loosely typed to save programming time given javascript's primary function is to manipulate content and styles on a web page and content on a web page is inherently text. It was supposed to be a simpler language focused on the problem of users interacting with a web page. But it has obviously grown beyond its initial role! For example if you are working on a web page shopping cart and the user types in 2 in a quantity input box you can go ahead and multiply with that number even though everything that is entered on a web page is a string. But I guess we would have to ask Brendan Eich to know for sure why he created JavaScript as a loosely typed language!
18th Oct 2018, 10:48 AM
Lisa F
Lisa F - avatar
18th Oct 2018, 9:29 AM
Janning⭐
Janning⭐ - avatar
+ 4
Lisa F I'd ask for sure iff I get a chance to meet with Brendan Eich..;)
18th Oct 2018, 11:56 AM
Sin Cos Ø
Sin Cos Ø - avatar
+ 3
Calviղ Could you explain , how it'd help to build coding more faster and easily?
18th Oct 2018, 11:58 AM
Sin Cos Ø
Sin Cos Ø - avatar
+ 2
1) suppose If you declare a variable without a "var" keyword then the variable is available globally 2) hoisting - variable can be used before its declaration So javascript is loosely typed
18th Oct 2018, 8:29 AM
onekpsc
18th Oct 2018, 6:22 PM
David Carroll
David Carroll - avatar