why we initialize array differently in php, javascript and etc [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
my question why we initialize array in different ways.
as i initialize array in php like array();
and in javascript in different way.
please anyone explain difference between array() and Array().
Thanks.

The shortest answer is that they are completely different languages and, just as different spoken languages have different grammar and vocabularies from each other, so do programming languages.
Beyond that, every programming language has to have some sort of runtime or compiler that understands the syntax, data structures, processing model, etc. And, each of those environments are free to implement those details as they see fit. This means that how an Array is internalized can be quite different between languages. But, to the programmer, we don't really need (or care) to know those implementation details.

Related

Should I learn javascript again after learning Reactjs? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I learned javascript 6 months ago and made many projects to practice it. After that I stop learning and revising javascript as I learned MERN stack. But now I am not feeling confident about my javascript skills.
Should I revise it again or should I continue to learn and practice Reactjs?
You should learn Javascript again if you want to be a good developer. There are 2 kinds of developers out there:
How group - This kind of developer knows how to do things. They know the syntaxes. Then when working on large applications they can't debug things well. They're just copy, & paste experts.
Why group - These people not only know how to do it but also know why the code doing this way. For example, they don't only know what is lexical scoping, but also how scoping works under the hood using a closure.
End of the day, I wanna say, if you only know how to write Javascript, then Javascript seems like a magical thing for you. But if you also know how Javascript works under the hood, you will be a magical thing to Javascript.

What is the time complexity of JavaScript methods? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is there any resource to know the time complexity of natively defined array and string methods in JavaScript?
I have to do guess work while I am using them to solve algorithm, but I want to be sure about what is the time complexity of those functions?
This question has been answered previously:
Time Complexity for Javascript Methods in V8
In short, it's not specified and the time complexity for common JS methods can differ between browsers.
Worse yet, some methods might not even exist or will behave differently between different browsers and browser versions!

Why does JavaScript have the Math object? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
In many languages, to find cosine, you use cos(x). But in JavaScript, you must use Math.cos(x). Why doesn't JavaScript spare us the 5 characters in Math., both making it easier to type and easier to read?
I have tried to Google this multiple times, and found no answers. Is there any practical reason for this that I have not yet found?
So far, there are three reasons I can think of:
The creators of JavaScript want to ensure that the math functions do not coincide with other functions users create (Like a function called 'cos()` that calculates, say, cosecant)
The creators of JavaScript thought that Math would make the code more readable
The creators of JavaScript perhaps didn't want any functions that have window as a parent (Though alert and prompt make this unlikely)
To hold the math functions without polluting the global namespace.

How to create objects with javascript / jquery [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm currently working on a web page where you can add many different "machines" and then specify certain things about each one.
My original thought was to create div's for each machine (which would contain common elements like "name", "operating system", etc), and then change the IDs according to the names. That being said, is this really the best approach? Is there some way to use javascript/jquery to essentially make classes?
I also read briefly about some javascript template libraries like mustache, but did not get too into them.
Not looking for you to write the code for me -- just wondering how I should approach this
Yes, you can use an array of JSON objects for this.
A Javascript library that supports model binding like AngularJS or Knockout can make displaying all the "machines" very easy with their foreach functionality.

how do you model your javascript? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm trying to model my javascript object using visio, visio doesn't support javascript data types.
Then I start thinking, how do you desing model your javascript code?
Cheers
In the past, I've used Open Source tools like Dia and just fudged the data types where needed...
It's enough to get the idea across, but you're definitely not going to get anything even close to code generation from it.
I prefer Object Oriented design - even for JavaScript - so I suggest Rational Rose. I like some of the features of OO (e.g. encapsulation and abstraction) and like to add some discipline to a potentially undisciplined environment - especially when working with developers new to JavaScript. Rose meets my needs.

Categories

Resources