The Browser Object Model (BOM) in JavaScript includes the properties and methods for JavaScript to interact with the web browser.BOM provides you with a window objects, for example, to show the width and height of the window. It also includes the window.screen object to show the width and height of the screen.ExampleYou can try to run the following code to learn how to get screen height and width −Live Demo document.write("Screen width: " + screen.width); document.write("Screen width: " + screen.width);
Use the screen.availHeight property to return the width of the user’s screen. The result will be in pixels and Taskbar feature won’t be included.ExampleYou can try to run the following code to learn how to work with the screen.availHeight property in JavaScript −Live Demo document.write("Height of the screen: "+screen.availHeight);
The source RegExp property in JavaScript is a read-only string property of RegExp objects. It contains the text of the RegExp pattern. This text does not include the delimiting slashes used in regular-expression literals, and it does not include the "g", "i", and "m" attributes.ExampleYou can try to run the following code to learn how to implement source RegExp property in JavaScript − JavaScript RegExp source Property var str = "JavaScript is an interesting scripting language"; var re = new RegExp( "script", "g" ); re.test(str); document.write("The regular expression is : " + re.source);
The window.history object is used to go back or to the next page of the web browser. It has the browser's history and comes with the following two methods −history.back − Go to previous URLhistory.next − Go to next URLExampleYou can try to run the following code to learn how to work with window.history object in JavaScript −Live Demo function backPage() { window.history.back() } function nextPage() { window.history.next() }
The following is the array and its elements −int[] arr = { 10, 20, 15 };Set negative value to positive elements.if (arr[i] > 0) arr[i] = -arr[i];Loop the above until the length of the array.for (int i = 0; i < arr.Length; i++) { Console.WriteLine(arr[i]); if (arr[i] > 0) arr[i] = -arr[i]; }Let us see the complete example.Example Live Demousing System; public class Demo { public static void Main(string[] args) { int[] arr = { 10, 20, 15 }; Console.WriteLine("Displaying elements..."); for (int i = 0; i < ... Read More
To return the “time” portion of the Date as a human-readable string, use the toTimeString() method in JavaScript. This method returns the time portion of a Date object in the human-readable form.ExampleYou need to run the following code to return only the time portion of a Date − JavaScript toTimeString Method var dateobject = new Date(2018, 0, 1, 14, 39, 7); document.write( dateobject.toTimeString() );
To convert a date to a string using the universal time convention, use the toUTCString() method. It returns converted the date to a string, using the universal time convention.ExampleYou can try to run the following code to learn how to convert a date to a string using UTC − JavaScript toUTCString Method var dateobject = new Date(2018, 0, 15, 14, 39, 7); document.write( dateobject.toUTCString() );
The "D" format specifier represents a custom date and time format string.The format string is defined by culture's DateTimeFormatInfo.LongDatePattern property.The custom format string is −dddd, dd MMMM yyyyExample Live Demousing System; using System.Globalization; class Demo { static void Main() { DateTime myDate = new DateTime(2018, 9, 20); Console.WriteLine(myDate.ToString("D", CultureInfo.CreateSpecificCulture("en-US"))); } }OutputThursday, September 20, 2018
Here is our LinkedList.int [] num = {1, 3, 7, 15}; LinkedList list = new LinkedList(num);To check whether the list contains an element or not, use the Contains() method. The following example checks for node 3 in the list.list.Contains(3)Above, returns True since the element is found as shown below −Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { int [] num = {1, 3, 7, 15}; LinkedList list = new LinkedList(num); foreach (var n in list) { Console.WriteLine(n); } ... Read More
The "C" (or currency) format specifier is used to convert a number to a string representing a currency amount.Let us see an example.double value = 139.87;Now to display the above number until three decimal places, use (“C3”) currency format specifier.value.ToString("C3", CultureInfo.CurrentCulture)Let us see another example.Example Live Demousing System; using System.Globalization; class Demo { static void Main() { double value = 234.66; // displays $ Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture)); Console.WriteLine(value.ToString("C3", CultureInfo.CurrentCulture)); } }Output$234.66 $234.660
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP