This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NDM Javascript Code Test Solutions | |
| ================================== | |
| 1. Fix the below Javascript code so that the correct index is printed to console.log on each iteration. | |
| Solution: | |
| (function() { | |
| var index, | |
| length = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Usage: | |
| // | |
| // ('http://www.example.com').withParam('foo', 'bar'); | |
| // -> http://www.example.com?foo=bar | |
| // | |
| // ('http://www.example.com').withParam('foo'); | |
| // -> http://www.example.com?foo | |
| // | |
| // Credit: Lessan Vaezi | |
| // (See: http://stackoverflow.com/a/487084/23341) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @name constructProxy | |
| * | |
| * @description | |
| * From a source object, generates and returns a proxy object. When a property | |
| * in the source object is invoked, it runs the function provided as the getter, | |
| * passing it the name of the property invoked as well as the full expression | |
| * that was invoked. Properties that are of type 'object' are simply copied over. | |
| * | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Common.context('#news-page', function($) { | |
| console.log(this.html()); | |
| }); | |
| // output: | |
| // <div id="#news-page"> | |
| // <h2>Australian broadband news and information</h2> | |
| // <p>Friday round-up</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // By JonathanConway.net | |
| // Based off original code by Andy E. http://stackoverflow.com/questions/901115/get-querystring-values-with-jquery/2880929#2880929 | |
| Object.prototype.isArray = function () { | |
| /// <summary> | |
| /// Returns true if this object is an array. | |
| /// </summary> | |
| return !(this.push === undefined); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery.extend(jQuery.expr[':'], { | |
| /// <summary> | |
| /// Filter out checkboxes which are checked. | |
| /// </summary> | |
| checked: function(element) { | |
| return element.checked; | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class ValidationExtensions | |
| { | |
| public static MvcHtmlString ValidationMessageHtmlFor<TModel, TProperty>( | |
| this HtmlHelper<TModel> htmlHelper, | |
| Expression<Func<TModel, TProperty>> expression, | |
| bool htmlEncode) | |
| { | |
| return new MvcHtmlString( | |
| HttpUtility.HtmlDecode( | |
| htmlHelper.ValidationMessageFor<TModel, TProperty>( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.extend($.expr[':'], { | |
| /// <summary> | |
| /// Filters on whether the element has the same css property & value as specified. | |
| /// Example: $('a:css(color:blue)') returns only links which are blue. | |
| /// </summary> | |
| css: function(element, index, params) { | |
| var style = params[3].split(':'); | |
| return element.style[style[0]] === style[1]; | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Number.prototype.between = function(n1, n2) { return this >= n1 && this <= n2; } |
OlderNewer