To create a syntax-highlighting code with JavaScript, use the prettify library. Add the following in your code to add the library for syntax highlighting −To use it, add the following to your tag − Code comes here
Use the keydown event in JavaScript to get to know which keys are pressed at once. The following is the script −Examplevar log = $('#log')[0], keyPressed = []; $(document.body).keydown(function (evt) { var li = keyPressed [evt.keyCode]; if (!li) { li = log.appendChild(document.createElement('li')); keyPressed [evt.keyCode] = li; } $(li).text(Key Down: ' + evt.keyCode); $(li).removeClass('key-up'); }); $(document.body).keyup(function (evt) { var li = keyPressed [evt.keyCode]; if (!li) { li = log.appendChild(document.createElement('li')); } $(li).text('Key Up: ' + evt.keyCode); $(li).addClass('key-up'); });
To get only the else part, just negate, using ! the operator in JavaScript. You can try to run the following code to achieve this −var arr = {}; if (!(id in arr)) { } else { }In addition, if you want the existence of a property in an object, then use hasOwnProperty −if (!arr.hasOwnProperty(id)) { } else { }
To declare a global variable, use the var at global scope − var myGlobalVariable; function display() { // } For JavaScript function, assign the property to a window − function display() { window. myGlobalVariable = …; }
To display million of rows of data to the users in a grid, use any of the following grids −S. NoGridDescription1DataTablesAllows adding advanced interaction controls to any HTML table.2IngridAllows resizing columns, paging, sorting, row and column styling to tables.3SlickGridUses virtual rendering to allow you to work with hundreds of thousands of items.Let us see the features of SlickGrid −Easily customizableComplete keyboard navigationEasily handles hundreds of thousands of rowsQuick rendering speedColumn autosizing availablePluggable cell formatters availableAllos creating new rows
JavaScript uses a semi-colon (;) to avoid any confusion in code, especially the beginning of a new line.ExampleYou can still use the following to avoid any chaos in the code −return { 'var':myVal } // using semi-colon; (function( $ ) { // }
The scope resolution operator in C# has a different meaning as compared with C++. In C++ the :: is used for global variables, whereas in C# it is related to namespaces.If you have a type that share an identifier in different namespace, then to identify them use the scope resolution operator.For example, to reference System.Console class, use the global namespace alias with the scope resolution operator.global::System.ConsoleExample Live Demousing myAlias = System.Collections; namespace Program { class Demo { static void Main() { myAlias::Hashtable h = new myAlias::Hashtable(); h.Add("Q", "1"); ... Read More
The IsFixedSize property of ArrayList class is used to get a value indicating whether the ArrayList has a fixed size.The following is an example stating the usage of isFixedSize property.Example Live Demousing System; using System.Collections; class Demo { public static void Main() { ArrayList arrList = new ArrayList(); Console.WriteLine("Adding some numbers:"); arrList.Add(45); arrList.Add(78); Console.WriteLine(arrList.Count); Console.WriteLine("myArrayList.IsFixedSize = " + arrList.IsFixedSize); } }OutputAdding some numbers: 2 myArrayList.IsFixedSize = FalseAbove we have added an array list.ArrayList arrList = new ArrayList();Then we have checked whether ... Read More
The IsReadOnly property of ArrayList class is useful to get a value indicating whether the ArrayList is read-only.Firstly, we have the following ArrayList.ArrayList arrList = new ArrayList();Then we have checked using the IsReadOnly Property.Console.WriteLine("myArrayList.IsReadOnly = " + arrList.IsReadOnly);The following is an example showing how to work with IsReadOnly property in ArrayList class.Example Live Demousing System; using System.Collections; class Demo { public static void Main() { ArrayList arrList = new ArrayList(); Console.WriteLine("myArrayList.IsReadOnly = " + arrList.IsReadOnly); } }OutputmyArrayList.IsReadOnly = False
Use lists in C# to store elements and fetch it. Let us see an example.Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { var subjects = new List(); subjects.Add("Maths"); subjects.Add("Java"); subjects.Add("English"); subjects.Add("Science"); subjects.Add("Physics"); subjects.Add("Chemistry"); foreach (var sub in subjects) { Console.WriteLine(sub); } } }OutputMaths Java English Science Physics ChemistryNow to check whether a list is empty or not, use the Count ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP