Skip to main content

Posts

Core Javascript coding test

// call , apply, bind //1. How to use bind() feature in javascript with example let button = function(content) { this.content = content; }; button.prototype.click = function() { console.log(`${this.content} clicked `); }; let newbtn = new button('add'); let boundclick = newbtn.click.bind(newbtn); boundclick(); //2. bind() using async funs let myobj = { asyncGet(cb) { cb(); }, parse() { console.log('parse called'); }, render() { this.asyncGet(function() { this.parse(); }.bind(this)) } }; myobj.render(); // ----------------------------JS Coding Test------------------------------------ //1. What does the following statement declares? var myArray = [ [ [] ] ]; // A. 3 dimension array //2.Question: What value is returned from the above statement? var test = "i'm a lasagna hog".split("").reverse().join(""); //Answer: "goh angasal a m'i" //3. What is returned ? 
Recent posts

Frontend developer Interview questions

1. Can you describe your workflow when you create a web page? 2. Name 3 ways to decrease page load. (perceived or actual load time) 3. Explain few Common Security Issues with Ajax. or limitations of Using Ajax on a Web Page? A. security, SEO search engine indexing, user experience, accessibility issues, browser integration, response time concerns, SEO 4. What is the difference between .call() and .apply()?  .call() is used when the number of the function’s arguments are known to the programmer  .apply() is used when the number is not known 5. Explain the purpose of each of the HTTP request types when used with a RESTful web service.   -- GET, POST, PUT, PATCH, DELETE, TRACE, OPTIONS, HEAD, Connect.     HEAD, GET, OPTIONS and TRACE) are defined as safe methods 6. Explain the difference between stateless and stateful protocols. Which type of protocol is HTTP? Explain your answer. -- A stateless communications protocol treats each request as an independent transac

How to use Fancy Ext.Logger?

How to customize Ext.Logger effectively? For development, We can customize Ext.Logger mechanism and add colors to text as below /** * Fancy Ext.Logger.warn(), error() * By including this file we'll force override of the Ext.Logger.warn() behavior. eg: Ext.Logger.error(errMsg); Ext.Logger.warn('Warning msg'); */ Ext.define('Master.util.Log', { singleton: true, /** * Logs color-coded console message; intended for development only * to be used in betwee debug directives. * @param {String} text to log */ warn: function(text) { console.log('%cWARN: %s', 'background: #222; color: orange', text); }, error: function(text) { console.log('%cERROR: %s', 'background: #d9e6ee; color: red', text); } }, function() { Ext.Logger.warn = Master.util.Log.warn; Ext.Logger.error = Master.util.Log.error; });

EXTJS4 Override AJAX Timeouts

EXTJS4: Set global default Ajax timeout for sencha application Version Info: Ext JS 4.2x If we want to increase the timeout globally across my application. ExtJS documentation makes it look like setting Ext.Ajax.timeout will increase all timeouts, it’s just not true. This code sets 5 mins for forms, stores and ajax proxies calls within MVC application. Code snippet: Ext.Ajax.timeout= 300000; // 300 seconds (5 mins) Ext.override(Ext.form.Basic, { timeout: Ext.Ajax.timeout / 1000 }); Ext.override(Ext.data.proxy.Server, { timeout: Ext.Ajax.timeout }); Ext.override(Ext.data.Connection, { timeout: Ext.Ajax.timeout }); // If you are using Ext.define in your code. It creates new class and does not override timeout property in base class.Hence use above code snippet. Ext.define('Test.data.Connection', { override: 'Ext.data.Connection', timeout: 120000 });

ExtJS4 - 2016 Fiddles

ExtJS Fiddles (2016) // In exjts 4.1.x and 4.2.0, destroy() will not destroy its children components? Components without store binding  http://jsfiddle.net/mustafa0x/qVM82/1/ windows with stores http://jsfiddle.net/mustafa0x/qVM82/3/ EXT Speech Recognition Wrapper https://fiddle.sencha.com/#fiddle/3lu&view/editor Custom Editor for Property Grid http://jsfiddle.net/existdissolve/wMcQk/ Infinite scroll grid 4.2 https://fiddle.sencha.com/#view/editor&fiddle/e04 Cell editing - load store after layout event http://docs.sencha.com/extjs/4.2.4/extjs-build/examples/build/KitchenSink/ext-theme-neptune/#cell-editing Grid cellediting https://fiddle.sencha.com/#fiddle/100a&view/editor doComponent Layout- style with google fonts https://fiddle.sencha.com/#fiddle/eoj Fieldset - clear fields https://fiddle.sencha.com/#fiddle/1bdg Generating a Checkbox Group from a Store https://druckit.wordpress.com/2015/02/12/ext-js-generating-a-checkbox-group-from-a

How to handle LoadMask effectively?

How to use Ext.LoadMask component for a stateless web application? I found an issue where loadMask z-index DIV element conflicted with modal window object z-index DIV element. loadmask component created for different target views for each screen and hidden but not destroyed. I spend good time to investigate issue in my application code. Version: EXT 4.2.0 Chrome - Browser Issues: var myMask = new Ext.LoadMask(mypanel , {msg:"Loading..."}); myMask.hide(); // Why myMask.hide(); simply destroy LoadMask instance, here DOM still exist in browser with style "visibility: hidden" Like this for more DIV element with this style are added to DOM. To work on my fix, I still see 'x-mask' element exist in dom even when my target view is destroyed. I want to understand difference between Ext.getBody().mask() /unmask() and var maskobj = new Ext.LoadMask({ msg: message, hideMode: 'display', target: targetComponent } ); maskobj.show(); Example:

Console.log How to turn on/off console in development

How to turn-off Console logs? Traditional browsers doesn't support console object. This is one way to turn off console logs for your web application. How to switch off console object in Production? Call this util method when Ext application is ready. i,e inside init() or Launch() of Ext.app.Application class Example: init: function(app) { handleConsoleFn(false, false); } /* * Call once at begining to ensure your app can safely call console.log() * and console.dir(),even on legacy browsers that don't support it.You may not get useful logging on those browsers, * but at least you won't generate errors. * @params alertFallback if 'true', all logs becomes alerts in Legacy browsers like IE, if necessary (keep 'false' in production) * @params debugModeON if 'true', console object will be enabled, (keep 'false' in production) */ handleConsoleFn: function(alertFallback, debugModeON) { var me = this; if (typeof console ===