Category Archives: JavaScript

JavaScript Array

An array is a collection of data values. we can store more than one values and retrieve values as per index. Also, we can store lists an array. Array indexes are zero-based, the first element in the array is 0, the second is 1, and so on.

Array Example:
var fruits = ["Apple", "Orange", "Banana", "Mango"];

Array Properties:
constructor: Returns the function that created the Array object’s prototype.
length: Sets or returns the number of elements in an array.
prototype: Allows you to add properties and methods to an Array object.

Array Methods:

concat(): Joins two or more arrays, and returns a copy of the joined arrays.

copyWithin(): Copies array elements within the array, to and from specified positions.

entries(): Returns a key/value pair Array Iteration Object.

every(): Checks if every element in an array pass a test.

fill(): Fill the elements in an array with a static value.

filter(): Creates a new array with every element in an array that pass a test.

find(): Returns the value of the first element in an array that pass a test.

findIndex(): Returns the index of the first element in an array that pass a test.

forEach(): Calls a function for each array element.

from(): Creates an array from an object.

includes(): Check if an array contains the specified element.

indexOf(): Search the array for an element and returns its position.

isArray(): Checks whether an object is an array.

join(): Joins all elements of an array into a string.

keys(): Returns a Array Iteration Object, containing the keys of the original array.

lastIndexOf(): Search the array for an element, starting at the end, and returns its position.

map(): Creates a new array with the result of calling a function for each array element.

pop(): Removes the last element of an array, and returns that element.

push(): Adds new elements to the end of an array, and returns the new length.

reduce(): Reduce the values of an array to a single value (going left-to-right).

reduceRight(): Reduce the values of an array to a single value (going right-to-left).

reverse(): Reverses the order of the elements in an array.

shift(): Removes the first element of an array, and returns that element.

slice(): Selects a part of an array, and returns the new array.

some(): Checks if any of the elements in an array pass a test.

sort(): Sorts the elements of an array.

splice(): Adds/Removes elements from an array.

toString(): Converts an array to a string, and returns the result.

unshift(): Adds new elements to the beginning of an array, and returns the new length.

valueOf(): Returns the primitive value of an array.

Custom Clone Button in Salesforce

Salesforce provides Clone functionality for some standard objects(Standard Clone button), However some standard objects do not have this button. For this purpose of cloning we will need to create custom button that will perform the functionality of cloning.

This cloning functionality can be achieved by writing a javascript for this custom button.

As an example lets create a custom button “Clone” on Account object that will clone the record.

Simply override your custom button “Clone” with the following javascript and you will have your custom Clone button that functions exactly like standard clone button

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 
window.parent.location.href="/{!Account.Id}/e?&clone=1&retURL=/{!Account.Id}";

Note: retUrl specifies the location where you want to be on press of back button.

Calling Visualforce Page From Javascript

Visualforce page that calls another Visualforce page upon confirming from javascript.

Visualforce Page:

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock>
            <apex:commandButton value="Open VF Page" onclick="OpenVFPage()"/>
        </apex:pageBlock>
    
    <script>
      function OpenVFPage(){
        var isConfirm = confirm('Do you want to open a new Visualforce Page?');
        if(isConfirm)
           window.open('/apex/YourVisualForcePage');
      }
     </script>
    </apex:form>
</apex:page>

Similarly, if you want to open a visualforce page from a custom button using javascript then use following piece of code.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 
var isConfirm = confirm('Do you want to open new Visualforce Page?');
if(isConfirm){
	window.parent.location.href="/apex/YourVisualforcePage";
}

Web Browser Language Identification Codes


Language Code
Afrikaans af
Albanian sq
Arabic (Standard) ar
Arabic (Algeria) ar-dz
Arabic (Bahrain) ar-bh
Arabic (Egypt) ar-eg
Arabic (Iraq) ar-iq
Arabic (Jordan) ar-jo
Arabic (Kuwait) ar-kw
Arabic (Lebanon) ar-lb
Arabic (Libya) ar-ly
Arabic (Morocco) ar-ma
Arabic (Oman) ar-om
Arabic (Qatar) ar-qa
Arabic (Saudi Arabia) ar-sa
Arabic (Syria) ar-sy
Arabic (Tunisia) ar-tn
Arabic (U.A.E.) ar-ae
Arabic (Yemen) ar-ye
Aragonese ar
Armenian hy
Assamese as
Asturian ast
Azerbaijani az
Basque eu
Bulgarian bg
Belarusian be
Bengali bn
Bosnian bs
Breton br
Bulgarian bg
Burmese my
Catalan ca
Chamorro ch
Chechen ce
Chinese zh
Chinese (Hong Kong) zh-hk
Chinese (PRC) zh-cn
Chinese (Singapore) zh-sg
Chinese (Taiwan) zh-tw
Chuvash cv
Corsican co
Cree cr
Croatian hr
Czech cs
Danish da
Dutch (Standard) nl
Dutch (Belgian) nl-be
English en
English (Australia) en-au
English (Belize) en-bz
English (Canada) en-ca
English (Ireland) en-ie
English (Jamaica) en-jm
English (New Zealand) en-nz
English (Philippines) en-ph
English (South Africa) en-za
English (Trinidad & Tobago) en-tt
English (United Kingdom) en-gb
English (United States) en-us
English (Zimbabwe) en-zw
Esperanto eo
Estonian et
Faeroese fo
Farsi fa
Fijian fj
Finnish fi
French (Standard) fr
French (Belgium) fr-be
French (Canada) fr-ca
French (France) fr-fr
French (Luxembourg) fr-lu
French (Monaco) fr-mc
French (Switzerland) fr-ch
Frisian fy
Friulian fur
Gaelic (Scots) gd
Gaelic (Irish) gd-ie
Galacian gl
Georgian ka
German (Standard) de
German (Austria) de-at
German (Germany) de-de
German (Liechtenstein) de-li
German (Luxembourg) de-lu
German (Switzerland) de-ch
Greek el
Gujurati gu
Haitian ht
Hebrew he
Hindi hi
Hungarian hu
Icelandic is
Indonesian id
Inuktitut iu
Irish ga
Italian (Standard) it
Italian (Switzerland) it-ch
Japanese ja
Kannada kn
Kashmiri ks
Kazakh kk
Khmer km
Kirghiz ky
Klingon tlh
Korean ko
Korean (North Korea) ko-kp
Korean (South Korea) ko-kr
Latin la
Latvian lv
Lithuanian lt
Luxembourgish lb
FYRO Macedonian mk
Malay ms
Malayalam ml
Maltese mt
Maori mi
Marathi mr
Moldavian mo
Navajo nv
Ndonga ng
Nepali ne
Norwegian no
Norwegian (Bokmal) nb
Norwegian (Nynorsk) nn
Occitan oc
Oriya or
Oromo om
Persian fa
Persian/Iran fa-ir
Polish pl
Portuguese pt
Portuguese (Brazil) pt-br
Punjabi pa
Punjabi (India) pa-in
Punjabi (Pakistan) pa-pk
Quechua qu
Rhaeto-Romanic rm
Romanian ro
Romanian (Moldavia) ro-mo
Russian ru
Russian (Moldavia) ru-mo
Sami (Lappish) sz
Sango sg
Sanskrit sa
Sardinian sc
Scots Gaelic gd
Sindhi sd
Singhalese si
Serbian sr
Slovak sk
Slovenian sl
Somani so
Sorbian sb
Spanish es
Spanish (Argentina) es-ar
Spanish (Bolivia) es-bo
Spanish (Chile) es-cl
Spanish (Colombia) es-co
Spanish (Costa Rica) es-cr
Spanish (Dominican Republic) es-do
Spanish (Ecuador) es-ec
Spanish (El Salvador) es-sv
Spanish (Guatemala) es-gt
Spanish (Honduras) es-hn
Spanish (Mexico) es-mx
Spanish (Nicaragua) es-ni
Spanish (Panama) es-pa
Spanish (Paraguay) es-py
Spanish (Peru) es-pe
Spanish (Puerto Rico) es-pr
Spanish (Spain) es-es
Spanish (Uruguay) es-uy
Spanish (Venezuela) es-ve
Sutu sx
Swahili sw
Swedish sv
Swedish (Finland) sv-fi
Swedish (Sweden) sv-sv
Tamil ta
Tatar tt
Teluga te
Thai th
Tigre tig
Tsonga ts
Tswana tn
Turkish tr
Turkmen tk
Ukrainian uk
Upper Sorbian hsb
Urdu ur
Venda ve
Vietnamese vi
Volapuk vo
Walloon wa
Welsh cy
Xhosa xh
Yiddish ji
Zulu zu