What is a List ? [JavaScript interview question] [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 2 years ago.
Improve this question
What exactly is a "List" in JavaScript?
I got asked this question and I'm a professional of five years but this made me fumble.
I understand Arrays, Stacks, Queues, even Linked Lists.
But isn't a List just an Array in JavaScript? Because then I got asked what the difference between a List and an Array was, and I said no difference - and never got to know if that was right.
I understand the differences between the data structures List and Array in C# and Python but I don't get this one for JavaScript.

I understand the downvotes ... it was indeed a dumb question, I think I should have known that Lists weren't a type in JavaScript and tackle the dumb question that way.
For anyone this may prove useful: For front-end engineer interviews, make sure you know that JavaScript is a dynamic language, meaning the data structures are very different from static typed languages like C and Java, and even have different meanings in Python even though Python is a dynamically typed language similar to JavaScript.

Related

Javascript: Renaming built in functions [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 Javascript, is it acceptable to rename built in functions. For example, in my code, I use document.querySelector() tons of times. This is extremely long and tedious to type every single time (even with autocomplete from the IDE's side). Therefore, I decided to create a new function with a shorter name like the following:
let qs = selector => document.querySelector(selector);
Is this an acceptable practice in the JS community? Is this considered bad code? If so, why? Additionally, if doing this is alright, what are some drawbacks?
Thanks.
No.
Someone is going to come behind you to edit your code.
They will then have to track down your renaming function to actually see what it does.
Create an snippet in your IDE if it’s that much of an issue for you.

Javascript Syntax: Variable Declarations [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 8 years ago.
Improve this question
I'm fairly new to Javascript, and filled with questions, most of which I'm able to find the the answers to online. However, there is the rare occurrence when my wording of a question doesn't correctly communicate the idea I'm trying to portray. That's when I come to Stack Overflow, and try to communicate more visually.
Which of these two examples is more commonly acceptable when programming with Javascript?
Method 1:
var one = 1;
var two = 2;
Method 2:
var one=1,
two=2;
Are there more specific (organizational) occasions when Method 2 should be used?
Example:
// Food
var pizza,
sushi,
cheeseburger;
// Utensils
var fork,
spoon,
excalibur;
Just in-case you believe the answer to this question is purely subjective, I pose a different question for you: which way (in terms of storage) is more efficient, and is the size of the difference insignificant for larger-scale web apps?
The virtual machine treats the two identically. There will be no performance difference between the two. Stylistically some developers prefer the former, while I have always used the latter. Ultimately whatever you find more readable and whatever is the communalized standard at your organization is the one to go with.

How to get the data I need from airbnb web page? [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 8 years ago.
Improve this question
I want to get the dates booked and price from the the airbnb page: https://www.airbnb.com.sg/rooms/2781352 under the "Calendar" tab of it.
I am quite newbie to this, and I want to python to do that, can I?
And what else should learn, javascript, PHP?
For extracting data from web pages, my first stop is Beautifulsoup. It is designed for just this purpose, and is excellent at it. Combine it with the great requests HTTP library (so much better and easier than urllib/urllib2/etc.) for getting the pages.
Both of these are Python modules, there is no need to learn any other programming languages to do it, although it greatly helps to have an understanding of HTML and DTDs (Document Type Definitions) for setting up paths.

What are some techniques to facilitate safe refactoring in Javascript? [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 8 years ago.
Improve this question
I'm coming from statically typed languages like C++ where there are tools (the compiler for one) that will remind me if I forget something obvious while refactoring. For example, if I change the number of arguments to a function but I forget to change all the calls to it. But it seems really easy to make this type of mistake in javascript. How do you avoid problems like this when refactoring javascript?
just like you do in c++/java. By writing tests.
Unit tests are the best. If you code is MVC, then you can certainly have unit tests with little effort, at least for the model layer. The benefit is you get feedback immediately. Check out QUnit
Functional tests via Selenium or equivalent are good too. They will find problems, but not immediately.
Only thing like that I can think of is: JSLint (http://jslint.com/)

Help impress interviewer with javascript and jQuery skills [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 9 years ago.
Improve this question
One of the interviewers asked to impress him with the JavaScript and CSS skills. He provided a link to two websites and asked to write a JavaScript application (page or pages) that takes content from one or both of these websites and demonstrates my command of jQuery and CSS. It doesn’t have to be useful to end-users, but it should be interesting to programmers.
What interesting things should I write? What would impress you in the candidate?
P.S.
The sites have real-estate information.
So, what would be the best way to read information from a given URL and extract some of it using jQuery?
That interview question is so subjective. What impresses one person might be basic to another. Why not ask a more meaningful question that demonstrates whether or not the candidate actually knows the language.
With all that said and if you really want to work for this company, I would study up on the basics of both js and jquery and really learn how to optimize basic functions. If you had to impress me then you should try to optimize a block of code as best you can without making the code unreadable. There's nothing better than clean, fast and readable code.

Categories