Home > Entrevistas, JavaScript > Javascript interview questions

Javascript interview questions

November 20, 2013 Leave a comment Go to comments

*how does “this” works in JavaScript?
– The this keyword alwasy refer to the owner of the function, or to the object that a function s a method of.
for instance: if you are using something like
window.function = myFunction(){
this.style.background = “#FFF”;

this is the window object;

and if you are doing something like

var myId = this.id;

this is the dom element which have the id=myDiv

*3 ways to decrease page load
– optimize: images, html, css, file concatenation(css Sprites, css sheets), file minification(gif, jpg, png, css optimized, js optimizer), cache page if not changing.
– minimize http request, js, css files.
– resize images.

*Why is it better to serve site assets from multiple domains?
Because some web browser have a limit request to hosts, chrome 6, ff & IE 8+ have 8, IE7 2.

*What is FOUC?
Flash of unstyled content… when you see pieces of content without style while finishing loading the page
– you avoid this setting some class to hide the element and changing the class of the element with js, and when document ready show the element

*what does a doctype do?
To validate an HMTL, and because browsers have diff rendering modes, clarifies what version of the markup language is the page written in,
this ensures that a browser makes the best-effort attempt to following the relevant specifications, //without this the browser runs in quirks mode.

*What is the difference between == and ===?
he identity (===) operator behaves identically to the equality (==) operator except no type conversion is done,
and the types must be the same to be considered equal.

*hashtable in js?
like an associative array, but u the key can be an object, which use the hash generated of the object.

*get parameters from url in js?
– you get the location.search and split it by the question mark, and then find the variable you are looking for, and obtaining the value by spliting by the equal “=” symbol.

*Can you get post parameters in js?
you can only get uri parameters

*what is the most common use of anonymus functions?
as arguments to other functions, exemple jquery handling events.

*what is a closure in js?
when you define a function inside another function to be created or executed when the other function is being used… //dubious

*What are undefined and undeclared variables?
undefined = variables that dont have an assigned value yet.
undeclared = variables that are not part of your code, not declared in the scope…

* What are the diff between attribute and property?
html = attribute
DOM = property

*Differences between native and hosts Objects?
Native objects = Object, Function, String, Date, Math
Host Objects = the enviroment objects(window, document, location, history…)

Categories: Entrevistas, JavaScript
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: