Fabric.js graphemeSplit() Method

The graphemeSplit() method is used to divide a specified string in the user perceived single units that is each characters of the specified string will be converted into a single unit of string.
Syntax:
graphemeSplit(textstring)
Parameters: This method accepts a parameter as mentioned above and described below:
- textstring: This parameter holds the string to divide.
Return Value: This method returns the array containing the graphemes that is the divided characters.
Example 1:
Javascript
<!DOCTYPE html> <html> <head> <script src= </script> <script type="text/javascript" src= </script> <script type="text/javascript" src= </script> </head> <body> <script type="text/javascript"> console.log(fabric.util.string.graphemeSplit("GFG")); console.log(fabric.util.string.graphemeSplit("G F G")); </script> </body> </html> |
Output:
["G","F","G"] ["G"," ","F"," ","G"]
Example 2:
Javascript
<!DOCTYPE html> <html> <head> <script src= </script> <script type="text/javascript" src= </script> <script type="text/javascript" src= </script> </head> <body> <script type="text/javascript"> console.log("Using graphemeSplit() Function:"); var value = "12ab"; console.log(fabric.util.string.graphemeSplit(value)); console.log("Without using graphemeSplit() Function:"); var value="12ab"; console.log(value); </script> </body> </html> |
Output:
Using graphemeSplit() Function: ["1","2","a","b"] Without using graphemeSplit() Function: 12ab
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!



