When to Use Anonymous JavaScript Functions

Vrundesha Joshi
Updated on 23-Jun-2020 06:58:06

330 Views

The code while using anonymous functions is more readable when handlers are to be defined inside the calling code. Anonymous functions are declared inline. Normally, inline functions are better since they can access variables in the parent scopes.It allows for creating a function without any names identifier. It can be used as an argument to other functions. You can call them using a variable name.This is how JavaScript anonymous functions can be used −var func = function() {    alert(‘This is anonymous'); } func();Here’s an example −//anonymous function var a = function() {    return 5; }

Debug JavaScript on iPad

Abhinanda Shri
Updated on 23-Jun-2020 06:57:14

705 Views

To debug JavaScript on the iPad, you need to open the Safari browser.Now enable Web Inspector in iOS. In the Settings app, select Safari. Tap the Advanced option and start Web Inspector −Now select Web Inspector −Use a USB cable to connect the iPad to Mac. Safari opens and your iPad now visible in the DEVELOP Menu. After selecting, start debugging JavaScript.

Different Navigator Methods Available

Jennifer Nicholas
Updated on 23-Jun-2020 06:56:24

241 Views

You can use several Navigator related properties in your web page. The following are the properties −Sr.NoProperties & Description1javaEnabled()This method determines if JavaScript is enabled in the client. If JavaScript is enabled, this method returns true; otherwise, it returns false.2plugings.refreshThis method makes newly installed plug-ins available and populates the plugins array with all new plug-in names. Netscape only.3preference(name, value)This method allows a signed script to get and set some Netscape preferences. If the second parameter is omitted, this method will return the value of the specified preference; otherwise, it sets the value. Netscape only.4taintEnabled()This method returns true if data tainting ... Read More

Role of clearTimeout Function in JavaScript

Srinivas Gorla
Updated on 23-Jun-2020 06:55:51

309 Views

If you have set a time using setTimeout() function, then you can clear it using the JavaScript clearTimeout() function.ExampleYou can try to run the following code learn how to implement clearTimeout() function in JavaScript −           JavaScript Animation                                                        Click the buttons below to handle animation                              

List All Installed Browser Plugins

Nitya Raut
Updated on 23-Jun-2020 06:55:20

1K+ Views

To list down all the plug-on installed in the web browser, use the JavaScript navigator object. The JavaScript navigator object includes a child object called plugins. This object is an array, with one entry for each plug-in installed on the browser.ExampleYou can try to run the following code to list down all the plug-in installed in your browser −           List of Plug-Ins                                       Plug-in Name             Filename             Description                                 for (i = 0;  i < navigator.plugins.length;  i++)             {                document.write("");                document.write(navigator.plugins[i].name);                                document.write("");                document.write(navigator.plugins[i].filename);                                document.write("");                document.write(navigator.plugins[i].description);                document.write("");             }                    

Filter Array Elements Based on a Predicate in C#

Chandu yadav
Updated on 23-Jun-2020 06:55:01

3K+ Views

Set an array.int[] arr = { 40, 42, 12, 83, 75, 40, 95 };Use the Where clause and predicate to get elements above 50.IEnumerable myQuery = arr.AsQueryable() .Where((a, index) => a >= 50);Let us see the complete code −Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static void Main() {       int[] arr = { 40, 42, 12, 83, 75, 40, 95 };       Console.WriteLine("Array:");       foreach (int a in arr) {          Console.WriteLine(a);       }       // getting elements above 70       IEnumerable myQuery = arr.AsQueryable() .Where((a, index) => a >= 50);       Console.WriteLine("Elements above 50...:");       foreach (int res in myQuery) {          Console.WriteLine(res);       }    } }OutputArray: 40 42 12 83 75 40 95 Elements above 50...: 83 75 95

Convert to Decimal Method in C#

Samual Sam
Updated on 23-Jun-2020 06:53:07

4K+ Views

Convert a specified value to a decimal number using the Convert.ToDecimal() method.We have a string here.string stringVal = "2,345.26";Now, let us use the Convert.ToDecimal() method to convert it to a decimal number.decimal decimalVal; decimalVal = System.Convert.ToDecimal(stringVal);Let us now see the complete example −Example Live Demousing System; public class Demo {    public static void Main() {       decimal decimalVal;       string stringVal = "2,345.26";       decimalVal = System.Convert.ToDecimal(stringVal);       System.Console.WriteLine("String converted to decimal = {0} ", decimalVal);    } }OutputString converted to decimal = 2345.26

Return a Chash Tuple from a Method

karthikeya Boyini
Updated on 23-Jun-2020 06:52:32

399 Views

Firstly, create a tuple as shown below that calls a method.var tuple = Show();The above statement calls the following method −static Tuple Show()Under the method, return the tuple as shown below −Example Live Demousing System; public class Demo {    public static void Main() {       var tuple = Show();       Console.WriteLine(tuple.Item1);       Console.WriteLine(tuple.Item2);       Console.WriteLine(tuple.Item3);       Console.WriteLine(tuple.Item4);       Console.WriteLine(tuple.Item5);    }    static Tuple Show() {       return Tuple.Create(3, 5, 7, 9, 11);    } }Output3 5 7 9 11

Set Tuple as a Method Parameter in C#

Arjun Thakur
Updated on 23-Jun-2020 06:51:59

5K+ Views

Firstly, set a tuplevar tuple = Tuple.Create(100, 200, 300);Now, pass the tuple as a method parameter −Show(tuple);Here’s our method.static void Show(Tuple tuple)Now call the tuple values one by one as shown below −Example Live Demousing System; public class Program {    public static void Main() {       var tuple = Tuple.Create(100, 200, 300);       Show(tuple);    }    static void Show(Tuple tuple) {       Console.WriteLine(tuple.Item1);       Console.WriteLine(tuple.Item2);       Console.WriteLine(tuple.Item3);    } }Output100 200 300

C# Program to Display the First Element from an Array

Ankith Reddy
Updated on 23-Jun-2020 06:51:22

2K+ Views

The following is our array −double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};To get the first element, use the First() method.myArr.AsQueryable().First();Let us see the complete code −Example Live Demousing System; using System.Linq; using System.Collections.Generic; class Demo {    static void Main() {       double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};       double res = myArr.AsQueryable().First();       Console.WriteLine(res);    } }Output20.5

Advertisements