The string slice() and substring() methods functionality is same but difference is that slice() can take negative integer parameters.
The string slice() and substring() methods functionality is same but difference is that slice() can take negative integer parameters.String slice() method example:-
The string slice() and substring() methods functionality is same but difference is that slice() can take negative integer parameters. If passing parameters value is negative that means slice() find substring end of the string. In this example user can see how to use this method.
Example:-
|
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s=" library://ns.adobe.com/flex/spark"xmlns:mx=" library://ns.adobe.com/flex/mx" creationComplete="init();"> <fx:Script><![CDATA[ textcontrol1.text = str; textcontrol2.text = substring1; textcontrol3.text = substring; textcontrol4.text = substring2; } ]]> </s:Application> |
In this example we have used slice() method in different types.
Output:-
